{include file="public/header" $title="初始化注册" /}

    <style>
        .layui-tab-item{height: 700px}
    </style>
</header>
<body>


<div class="layui-carousel" id="test1" lay-filter="test1">
    <div carousel-item="">
        <div >
            <form class="layui-form" action="" style="width: 30%;margin: 100px auto;">
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">数据库类型</label>
                    <div class="layui-input-inline">
                        <select name="type" id="cc">
                            <option value="1">MySQL</option>
                            <option value="2">SqLite</option>
                            <option value="3">PgSQL</option>
                            <option value="4">SqlServer</option>
                        </select>
                        {if isset($dataBase.type)}<script>$("[name='type']").val("{$dataBase.type}")</script>{/if}
                    </div>
                </div>
                <div class="layui-form-item" >
                    <label class="layui-form-label">服务器地址</label>
                    <div class="layui-input-block ">
                        <input type="text" name="hostname" lay-verify="title" autocomplete="off" placeholder="请输入服务器地址" class="layui-input  layui-input-inline">
                        {if isset($dataBase.hostname)}<script>$("[name='hostname']").val("{$dataBase.hostname}")</script>{/if}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">数据库名</label>
                    <div class="layui-input-block">
                        <input type="text" name="database"  autocomplete="off" placeholder="请输入数据库名" class="layui-input  layui-input-inline" >
                        {if isset($dataBase.database)}<script>$("[name='database']").val("{$dataBase.database}")</script>{/if}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" name="username"  autocomplete="off" placeholder="请输入用户名" class="layui-input layui-input-inline" >
                        {if isset($dataBase.username)}<script>$("[name='username']").val("{$dataBase.username}")</script>{/if}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input type="text" name="password"  autocomplete="off" placeholder="请输入密码" class="layui-input layui-input-inline" >
                        {if isset($dataBase.password)}<script>$("[name='password']").val("{$dataBase.password}")</script>{/if}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">端口</label>
                    <div class="layui-input-block">
                        <input type="text" name="hostport"  autocomplete="off" placeholder="请输入端口" class="layui-input layui-input-inline" >
                        {if isset($dataBase.hostport)}<script>$("[name='hostport']").val("{$dataBase.hostport}")</script>{/if}
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">数据库编码</label>
                    <div class="layui-input-inline">
                        <select name="charset">
                            <option value="1">utf8</option>
                            <option value="2">gbk</option>
                        </select>
                        {if isset($dataBase.charset)}<script>$("[name='charset']").val("{$dataBase.charset}")</script>{/if}
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-input-inline" lay-submit="" lay-filter="next2" type="button">下一步</button>
                    </div>
                </div>
            </form>
        </div>
        <div>
            <form class="layui-form" action="" style="height: 100%;width: 20%;margin: 200px auto;">

                <div class="layui-form-item" >
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-block ">
                        <input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="请输入管理员账号" class="layui-input  layui-input-inline">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input type="text" name="pwd"  autocomplete="off" placeholder="请输入管理员密码" class="layui-input  layui-input-inline" >
                    </div>
                </div>

                <div class="layui-form-item" >
                    <div class="layui-input-block">
                        <button class="layui-btn layui-input-inline" lay-submit="" lay-filter="goSub" type="button">完成</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script>

    layui.use(['carousel', 'form'], function(){
        var carousel = layui.carousel
                ,form = layui.form;

        //常规轮播
        carousel.render({
            elem: '#test1'
            ,arrow: 'hover'
            ,full:true
            ,autoplay:false
        });

        //下一步按钮操作
        form.on("submit(next2)",function(data){
            $.post("{:url('nadmin/sundry/addDatabaseConf')}",data.field,function(obj){
                if(obj.status == 1)
                {
                    $(".layui-carousel-arrow").eq(1).click();
                }else{
                    layer.msg(obj.msg)
                }
            },'json')

        })
        //完成操作
        form.on("submit(goSub)",function(data){
            $.post("{:url('nadmin/sundry/addAdminer')}",data.field,function(obj){
                layer.msg(obj.msg,{time:3000},function(){
                    if(obj.status ==1)
                    {
                        //注册成功跳到首页
                        window.location.href="{:url('nadmin/login/index')}";
                    }
                });

            },'json')
        })

    });
</script>

</html>